<?php
class admin_nav_controller extends common
{
	function index_action(){
		$menurows=$this->obj->DB_select_all("admin_navigation","`display`<>1 order by `sort` desc");
		$i=0;$j=0;$a=0;$b=0;
		if(is_array($menurows)){
			foreach($menurows as $key=>$v){
				if($v[keyid]==0){
					$navigation[$i][id]=$v[id];
					$navigation[$i][name]=$v[name];
					$navigation[$i]['sort']=$v['sort'];
					$i++;
				}
				if($v[menu]==2){
					$menu[$j][id]=$v[id];
					$menu[$j][name]=$v[name];
					$menu[$j][url]=$v[url];
					$j++;
				}
			}
		}
		if(is_array($navigation)){
			foreach($navigation as $va){
				if(is_array($menurows)){
					foreach($menurows as $key=>$v){
						if($v[keyid]==$va[id]){
							if(!is_array($one_menu[$va[id]]))$a=0;
							$one_menu[$va[id]][$a][id]=$v[id];
							$one_menu[$va[id]][$a][name]=$v[name];
							$one_menu[$va[id]][$a]['sort']=$v['sort'];
							$a++;
							foreach($menurows as $key=>$vaa){
								if($vaa[keyid]==$v[id]){
									if(!is_array($two_menu[$v[id]]))$b=0;
									$two_menu[$v[id]][$b][id]=$vaa[id];
									$two_menu[$v[id]][$b][name]=$vaa[name];
									$two_menu[$v[id]][$b][url]=$vaa[url];
									$two_menu[$v[id]][$b]['sort']=$vaa['sort'];
									$two_menu[$v[id]][$b]['menu']=$vaa[menu];
									$two_menu[$v[id]][$b]['display']=$vaa[display];
									$b++;
								}
							}
						}
					}
				}
			}
		}
		$this->yunset("one_menu",$one_menu);
		$this->yunset("two_menu",$two_menu);
		$this->yunset("navigation",$navigation);
		$this->yuntpl(array('admin/admin_navigation'));
	}
}

?>